
<template>
	<view>
		<uni-popup ref="popupr" type="bottom" background-color="#fff" @change="bindClose">
			<view class="popup-content" style="height:930rpx">
				<view class="downs" @click="bindClose($event)">
					<view class="downs-btn"></view>
					<view class="tits">{{ tits }}</view>
				</view>
				<view class="base-line" ></view>

				<scroll-view scroll-y="true" style="height: 680rpx; padding-top: 36rpx">
					<view class="base-rows">
						<view class="rows_text">{{lveText}}</view>
						<view class="name_row" v-for="(item,i) in seleObjArr" :key="i" @click.stop="selectFunc(item,i)">
							<view class="name_row_item1" >
								<block v-if="!item.floorElevatorId || item.floorElevatorId === -1">
									<uni-icons v-show="item.acts" color="#0091ff" size="20" style="margin-right:4rpx" type="checkbox-filled" />
									<uni-icons v-show="!item.acts" color="#ccc" size="20" style="margin-right:4rpx" type="circle" />
								</block>
								<uni-icons v-if="item.floorElevatorId && item.floorElevatorId !== -1" size="20" color="#ccc" style="margin-right:4rpx" type="checkbox" />
							</view>
							<view class="name_row_item2">
								<view class="name_row_item2_text">{{(item.buildingName||'')+(item.elevatorAddress||'')}}</view>
								<view class="name_row_item2_text" style="color: #999;">{{item.buildingAddress || '--'}}</view>
							</view>
						</view>
						<view class="name_row_empty" v-if="seleObjArr.length === 0">
							<view>
								<image style="width: 64rpx;height: 64rpx;" src="/static/images/default.png"></image>
							</view>
							<view class="empty_tit">暂无数据</view>
						</view>
					</view>

				</scroll-view>

				<view class="bottoms">
					<!-- <view class="reSet" @click="bindClose($event, 1)">取消</view> -->
					<view class="submit" @click="submitDate">{{submitText}}</view>
				</view>
			</view>
		</uni-popup>

	</view>
</template>

<script>
export default {
	props: {
		tits: {
			type: String,
			default: '搜索电梯'
		},
		seleArrs: {
			type: Array,
			default: []
		},
		selectedArr:{
			type: Array,
			default: []
		},
		seleShows:{
			type:Boolean,
			default: []
		},
		isBuildingsShow:{//该参数用于其他页面使用到该组件时，用于控制是否显示对应信息
			type:Boolean,
			default: false
		},
		submitText: {
			type: String,
			default: '确认'
		},
		lveText: {
			type: String,
			default: '已进入工单作业范围，请选择工单签到'
		},

	},
	data() {
		return {
			selectValue: [],// 日期选择
			selectDate: null,
			keywords: '',
			seleObjArr: [],
			seleObjArrTwo:[]
		};
	},
	watch:{
		seleShows(val) {
			if (val) {
				this.$refs.popupr.open();
				this.$nextTick(() => {
					this.selectedArr.forEach(element => {
						this.seleObjArr.forEach(item => {
							if (element.id == item.id) {
								item.acts = true;
							}
						});
					});
				});
			}
		},
		seleArrs(val) {
			this.seleObjArr = val;
			this.seleObjArrTwo = JSON.parse(JSON.stringify(val));
		},
	},
	methods: {
		bindChange(e) {
			this.selectDate = e.detail.value;
		},
		selectFunc(obj,i) {
			// this.seleObjArr[i].acts = !this.seleObjArr[i].acts;
			this.seleObjArr.forEach((item, index) => {
				item.acts = false;
				if (index === i) {
					item.acts = !item.acts;
				}
			})
			this.$forceUpdate();
		},
		bindClose(e,) {
			if (!e.show) {
				// this.$refs.popupr.close()
				this.seleObjArr = this.seleObjArrTwo;
				this.seleObjArr.forEach(item => {
					item.acts = false;
				});
				this.$emit('bindClose', false);
			}
		},
		
		// 确认
		submitDate() {

			this.$emit('selectChecd', this.seleObjArr);
		},
	}

};
</script>

<style lang="scss" scoped>

.popup-content {
	display: flex;
	flex-direction: column;
	padding: 30rpx;
	// height: 50px;
	background-color: #fff;
	border-radius: 8rpx 8rpx 0rpx 0rpx;
	position: relative;
	.tits{
		font-weight: bold;
		color: #333;
		font-size: 32rpx;
}
	.name_row_empty {
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: center;
		height: 200rpx;
		font-size: 26rpx;
		color: #999999;
	}
	
	.base-line {
		position: absolute;
		left: 0;
		right: 0;
		top:110rpx;
		
		width: 100%;
		height: 2rpx;
		background-color: #E9E9E9;
		// border-bottom: 8rpx solid #F3F6F8;
	}
	.base-rows{
		// margin-top: 20rpx;
		.rows_text{
			font-size: 24rpx;
			color: #999999;
			margin-top: 10rpx;
		}
		.name_row {
			display: flex;
			align-items: center;
			// margin-top: 20rpx;
			border-bottom: 2rpx#E9E9E9 solid;
			padding: 26rpx 0;

			.name_row_item1 {
				width: 50rpx;
				font-size: 24rpx;
				color: #333333;
			}

			.name_row_item2 {
				flex: 1;
				font-size: 26rpx;
				color: #333333;
				.name_row_item2_text{
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
			}
		}
	}

	.downs {
		width: 100%;

		.downs-btn {
			width: 64rpx;
			height: 10rpx;
			background: #d8d8d8;
			border-radius: 6rpx;
			margin: 0 auto;
		}
	}

	.bottoms {
		display: flex;
		height: 100rpx;
        border-top: 2rpx solid #eee;
        line-height: 100rpx;
        align-items: center;
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		padding: 0 20rpx;
		.submit {
			display: flex;
			flex: 1;
			height: 70rpx;
			justify-content: center;
			align-items: center;
			border-radius: 8rpx;
			font-size: 28rpx;
		}

		.reSet {
			background-color: #f5fbff;
			color: #0091ff;
			margin-right: 10rpx;
		}

		.submit {
			background-color: $theme-color;
			color: #fff;
		}
	}
}
</style>